package com.sojson.config.converter;

import java.util.Date;

import org.springframework.core.convert.converter.Converter;

import com.sojson.util.DateUtil;

/**
 * {@link org.springframework.web.bind.annotation.RequestParam}时间转换器
 * 
 * @author liu
 * @date 2021-04-24
 */
public class DateConverter implements Converter<String, Date> {

    /**
     * 将String字符串转换成Date
     * 
     * @param date 被转换的字符串
     * @return
     */
    @Override
    public Date convert(String source) {
        return stringToDate(source);
    }

    /**
     * 将String字符串转换成Date
     * 
     * @param date 被转换的字符串
     * @return
     */
    private Date stringToDate(String source) {
        return DateUtil.stringToDate(source);
    }

}